<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //6.统计字符:统计字符串的大写字母，小写字母，几个数字，几个符号
        //absBJIU36541.,,.
        var str = window.prompt('请输入字符串');
        var shuzi = 0;
        var xxzm = 0;
        var dxzm = 0;
        var tsfh = 0;
        for (var i = 0; i < str.length; i++) {
            var code = str.charCodeAt(i);
            //ascii  数字48-57
            if (code >= 48 && code <= 57) {
                shuzi++;
            } else if (code >= 65 && code <= 90) {
                xxzm++;
            } else if (code >= 97 && code <= 122) {
                dxzm++;
            } else {
                tsfh++;
            }
        }
        document.write(str + '有数字' + shuzi);
        document.write('<br>');
        document.write(str + '有小写字母' + xxzm);
        document.write('<br>');
        document.write(str + '有大写字母' + dxzm);
        document.write('<br>');
        document.write(str + '有符号' + tsfh);
        document.write('<br>');


        //7.抓球问题：红球5个，黑球7个,白球9个，随机取出12个，计算可能的颜色组成有多少种
        var count = 0;
        for (var x = 0; x <= 5; x++) {
            for (var y = 0; y <= 7; y++) {
                for (var z = 0; z <= 9; z++) {
                    if (x + y + z == 12) {
                        // document.write("红球"+x+"个，黑球"+y+"个,白球"+z+"个，取出12个<br>");
                        count++;
                    }
                }
            }
        }
        document.write("红球5个，黑球7个,白球9个，随机取出12个,可能的颜色组成有" + count);
        document.write('<br>');

        //用1元纸币兑换1分，2分，5分的硬币，要求兑换总数为50，问可以有多少种组合
        var count = 0;
        for (var a = 0; a <= 50; a++) {
            for (var b = 0; b <= 50 - a; b++) {
                var c = 50 - a - b;
                if (a * 1 + b * 2 + 5 * c == 100) {
                    // document.write("一分:"+a+"个，二分"+b+"个,五分"+c+"个，组合为1元<br>");
                    count++
                };
            }
        }
        document.write("1元纸币兑换1分，2分，5分的硬币，要求兑换总数为50，组合有" + count);
        document.write('<br>');

        //9：九九乘法表
        for (i = 1; i <= 9; i++) {
            for (j = 1; j <= i; j++) {
                document.write(i + '*' + j + "=" + i * j);
                if (j != i) {
                    document.write(' ');
                }
            }
            document.write('<br>');
        }

        //数字处理，用户输入一个正证书，将该正整数倒序输出，并求各位数字相加之和
        var num = window.prompt("请输入一个正整数:")
        var sum = 0;
        if (num < 0) {
            document.write('-');
            num *= -1
        }

        var str = num.toString();
        for (var i = 0; i < str.length; i++) {
            document.write(str.charAt(str.length - 1 - i));
            var code = str.charCodeAt(i);
            if (code >= 48 && code <= 57) {
                sum = sum + (code - 48);
            }
        }
        document.write('<br>');
        document.write('各位数字的和' + sum + '<br>');


    </script>
</body>

</html>